---
category: Math
created: '2021-04-05'
title: Check if a point is inside a rectangle
updated: '2021-10-13'
---

**JavaScript version**

```js isInside.js
const isInside = (point, rect) =>
    point.x > rect.left && point.x < rect.right && point.y > rect.top && point.y < rect.bottom;
```

**TypeScript version**

```ts isInside.ts
interface Point {
    x: number;
    y: number;
}

interface Rect {
    bottom: number;
    left: number;
    top: number;
    right: number;
}

const isInside = (point: Point, rect: Rect): boolean =>
    point.x > rect.left && point.x < rect.right && point.y > rect.top && point.y < rect.bottom;
```
